#include "data-reader.h"
#include <math.h>
#include <gtest/gtest.h>

TEST(DataReaderTest, GetImages) {
  vector<Image*> images = DataReader::GetImages("training-9k.txt");
  ASSERT_EQ(9000, (int) images.size());
  for (size_t i = 0; i < images.size(); ++i) {
    delete images[i];
  }
}

TEST(DataReaderTest, Weights) {
  vector<double> weights;
  weights.push_back(0.0);
  weights.push_back(1.0);
  DataReader::DumpWeights(weights, "data-reader-test.tmp");
  vector<double> read_weights =
    DataReader::ReadWeights("data-reader-test.tmp");
  printf("%f %f\n", read_weights[0], read_weights[1]);
  ASSERT_EQ(weights.size(), read_weights.size());
  EXPECT_DOUBLE_EQ(0.0, read_weights[0]);
  EXPECT_DOUBLE_EQ(1.0, read_weights[1]);
}
